#include <iostream>
using namespace std;

//
//class A {
//public:
//	A(const char* s) { cout << s << endl; }
//	~A() {}
//};
//class B : public A
//{
//public:
//	B(const char* s1, const char* s2) :A(s1) { cout << s2 << endl; }
//};
//class C : public A
//{
//public:
//	C(const char* s1, const char* s2) :A(s1) { cout << s2 << endl; }
//};
//class D :public B, public C   //继承顺序改变
//{
//public:
//	D(const char* s1, const char* s2, const char* s3, const char* s4)
//		:B(s1, s2), C(s1, s3) //构造顺序是不是跟声明顺序无关  --->跟继承顺序有关
//	{
//		cout << s4 << endl;
//	}
//};
//
//
//int main()
//{
//	D* p = new D("class A", "class B", "class C", "class D");   //A构造的调用，紧接着是B-->C  -->D
//	delete p;
//	return 0;
//}
////有virtual   --->ABCD
////去掉virtual  -->ABACD  


//class Base1 {
//public:
//	int _b1;
//};
//class Base2 {
//public:
//	int _b2;
//};
//
//class Derive :public Base1, public Base2 {
//public:
//	int _d;
//};
//
//int main()
//{
//	Derive d;
//	Base1* ptr1 = &d;
//	Base2* ptr2 = &d;
//	Derive* ptr3 = &d;
//	return 0;
//}
//
//// ptr1 =ptr2=ptr3      ptr1 !=ptr2!=ptr3     ptr1 ==ptr2!=ptr3   ptr1 ==ptr3!=ptr2


class A {
public:
	virtual void fun1() { cout << "A::func1()" << endl; }
};

class B:public A {
public:
	virtual void fun1() { cout << "B::func1()" << endl; }
};

void func(A p)   
{
	p.fun1();
}

int main()
{
	B b;
	func(b);

}


